import 'package:flutter/material.dart';
import '../l10n/app_localizations.dart';

class TunnelLinkWidget extends StatelessWidget {
  final String tunnelUrl;
  final VoidCallback onCopy;
  final VoidCallback onOpen;

  const TunnelLinkWidget({
    Key? key,
    required this.tunnelUrl,
    required this.onCopy,
    required this.onOpen,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final isSmallScreen = MediaQuery.of(context).size.width < 600;

    return Container(
      margin: EdgeInsets.only(top: isSmallScreen ? 8 : 12),
      padding: EdgeInsets.all(isSmallScreen ? 12 : 16),
      decoration: BoxDecoration(
        color: const Color(0xFF1E2328),
        borderRadius: BorderRadius.circular(6),
        border: Border.all(color: Colors.green.withOpacity(0.3)),
      ),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        mainAxisSize: MainAxisSize.min,
        children: [
          Text(
            AppLocalizations.of(context)!.tunnelLink,
            style: TextStyle(
              color: Colors.white,
              fontSize: isSmallScreen ? 14 : 16,
              fontWeight: FontWeight.bold,
            ),
          ),
          SizedBox(height: isSmallScreen ? 8 : 10),
          SelectableText(
            tunnelUrl,
            style: TextStyle(
              color: Colors.green,
              fontSize: isSmallScreen ? 12 : 14,
              fontFamily: 'monospace',
            ),
          ),
          SizedBox(height: isSmallScreen ? 4 : 6),
          Row(
            children: [
              Flexible(
                child: ElevatedButton(
                  onPressed: onCopy,
                  style: ElevatedButton.styleFrom(
                    backgroundColor: Colors.green,
                    padding: EdgeInsets.symmetric(
                      horizontal: isSmallScreen ? 12 : 16,
                      vertical: isSmallScreen ? 8 : 10,
                    ),
                    minimumSize: Size(0, isSmallScreen ? 36 : 40),
                  ),
                  child: Text(
                    AppLocalizations.of(context)!.copy,
                    style: TextStyle(
                      fontSize: isSmallScreen ? 12 : 14,
                      color: Colors.white,
                    ),
                  ),
                ),
              ),
              SizedBox(width: isSmallScreen ? 8 : 12),
              Flexible(
                child: ElevatedButton(
                  onPressed: onOpen,
                  style: ElevatedButton.styleFrom(
                    backgroundColor: Colors.blue,
                    padding: EdgeInsets.symmetric(
                      horizontal: isSmallScreen ? 12 : 16,
                      vertical: isSmallScreen ? 8 : 10,
                    ),
                    minimumSize: Size(0, isSmallScreen ? 36 : 40),
                  ),
                  child: Text(
                    AppLocalizations.of(context)!.open,
                    style: TextStyle(
                      fontSize: isSmallScreen ? 12 : 14,
                      color: Colors.white,
                    ),
                  ),
                ),
              ),
            ],
          ),
        ],
      ),
    );
  }
}
